// import Vue from 'vue'
// import Router from 'vue-router'

Vue.use(VueRouter)

const login = r => require.ensure([], () => r(require('@/page/gift/login')), 'login')
const register = r => require.ensure([], () => r(require('@/page/gift/register')), 'register')
const manage = r => require.ensure([], () => r(require('@/page/gift/manage')), 'giftList')
// const home = r => require.ensure([], () => r(require('@/page/home')), 'home')
const adminHome = r => require.ensure([], () => r(require('@/page/admin/adminHome')), 'adminhome')
const uploadExpress = r => require.ensure([], () => r(require('@/page/admin/uploadExpress')), 'uploadExpress')
const giftManager = r => require.ensure([], () => r(require('@/page/admin/giftManager')), 'giftManager')
const expressManager = r => require.ensure([], () => r(require('@/page/admin/expressManager')), 'expressManager')
const moneyManager = r => require.ensure([], () => r(require('@/page/admin/moneyManager')), 'moneyManager')
const orderQuery = r => require.ensure([], () => r(require('@/page/admin/orderQuery')), 'orderQuery')
const priceManager = r => require.ensure([], () => r(require('@/page/admin/priceManager')), 'priceManager')
const userManager = r => require.ensure([], () => r(require('@/page/admin/userManager')), 'userManager')
const levelManager = r => require.ensure([], () => r(require('@/page/admin/levelManager')), 'levelManager')
const batchManager = r => require.ensure([], () => r(require('@/page/admin/batchManager')), 'batchManager')
const depositManager = r => require.ensure([], () => r(require('@/page/admin/depositManager')), 'depositManager')
const roleManager = r => require.ensure([], () => r(require('@/page/admin/roleManager')), 'roleManager')
const siteManager = r => require.ensure([], () => r(require('@/page/admin/siteManager')), 'siteManager')
const keyValueManager = r => require.ensure([], () => r(require('@/page/admin/keyValueManager')), 'keyValueManager')

const cainiao = r => require.ensure([], () => r(require('@/page/admin/cainiao')), 'cainiao')

const giftList = r => require.ensure([], () => r(require('@/page/gift/giftList')), 'giftList')
const setAddress = r => require.ensure([], () => r(require('@/page/gift/setAddress')), 'setAddress')
const points = r => require.ensure([], () => r(require('@/page/gift/points')), 'points')
const consume = r => require.ensure([], () => r(require('@/page/gift/consume')), 'consume')

const address = r => require.ensure([], () => r(require('@/page/gift/address')), 'address')
const deliveryRecords = r => require.ensure([], () => r(require('@/page/gift/deliveryRecords')), 'deliveryRecords')
const myInfo = r => require.ensure([], () => r(require('@/page/gift/myInfo')), 'myInfo')
const teach = r => require.ensure([], () => r(require('@/page/gift/teach')), 'teach')
const notice = r => require.ensure([], () => r(require('@/page/gift/notice')), 'notice')

// const userInfo = r => require.ensure([], () => r(require('@/page/userInfo')), 'userInfo')
const userinfolist = r => require.ensure([], () => r(require('@/page/admin/userinfolist')), 'userinfolist')

const accountDetailList = r => require.ensure([], () => r(require('@/page/admin/accountDetailList')), 'accountDetailList')

// const admin = r => require.ensure([], () => r(require('@/page/admin')), 'admin')
const statistic = r => require.ensure([], () => r(require('@/page/admin/statistic')), 'statistic')

const routes = [
  // {
  //   path: '/',
  //   redirect: '/home'
  // },
  {
    path: '/login',
    component: login
  },
  {
    path: '/register',
    component: register,
    meta: ['数据管理', '用户列表']
  },
  // {
  //   path: '/admin',
  //   component: admin
  // },
  {
    path: '/userinfolist',
    component: userinfolist,
    meta: {
      title: '用户充值消费记录',
      requireAuth: true
    }
  },
  {
    path: '/accountDetailList',
    component: accountDetailList,
    meta: {
      title: '账户明细',
      requireAuth: true
    }
  },
  {
    path: '/admin',
    component: adminHome,
    meta: {
      title: '管理',
      requireAuth: true
    },
    name: '',
    children: [
      // {
      //   path: '',
      //   redirect: '/uploadexpress'
      // },
      {
        path: 'uploadexpress',
        component: uploadExpress,
        meta: ['上传快递']
      },
      {
        path: 'orderquery',
        component: orderQuery,
        meta: ['订单查询']
      },
      {
        path: 'moneymanager',
        component: moneyManager,
        meta: ['调账管理']
      },
      {
        path: 'expressmanager',
        component: expressManager,
        meta: ['快递管理']
      },
      {
        path: 'cainiao',
        component: cainiao,
        meta: {
          title: '菜鸟快递',
          requireAuth: true
        }
      },
      {
        path: 'giftmanager',
        component: giftManager,
        meta: {
          title: '礼物管理',
          requireAuth: true
        }
      }, {
        path: 'pricemanager',
        component: priceManager,
        meta: {
          title: '价格管理',
          requireAuth: true
        }
      }, {
        path: 'usermanager',
        component: userManager,
        meta: {
          title: '用户管理',
          requireAuth: true
        }
      }, {
        path: 'levelmanager',
        component: levelManager,
        meta: {
          title: '等级管理',
          requireAuth: true
        }
      }, {
        path: 'statistic',
        component: statistic,
        meta: {
          title: '统计',
          requireAuth: true
        }
      }, {
        path: 'batchmanager',
        component: batchManager,
        meta: {
          title: '批量管理',
          requireAuth: true
        }
      }, {
        path: 'depositmanager',
        component: depositManager,
        meta: {
          title: '充值管理',
          requireAuth: true
        }
      }, {
        path: 'rolemanager',
        component: roleManager,
        meta: {
          title: '角色管理',
          requireAuth: true
        }
      }, {
        path: 'sitemanager',
        component: siteManager,
        meta: {
          title: '站点管理',
          requireAuth: true
        }
      }, {
        path: 'keyvaluemanager',
        component: keyValueManager,
        meta: {
          title: '站点配置管理',
          requireAuth: true
        }
      }
    ]
  },
  {
    path: '/',
    component: manage,
    redirect: 'giftList',
    meta: {
      title: '主页',
      requireAuth: true // 添加该字段，表示进入这个路由是需要登录的
    },
    name: '',
    children: [{
      path: 'deliveryRecords',
      component: deliveryRecords
    }, {
      path: 'giftList',
      component: giftList
    }, {
      path: 'setAddress',
      component: setAddress
    }, {
      path: 'points',
      component: points,
      name: points
    }, {
      path: 'myInfo',
      component: myInfo
    }, {
      path: 'consume',
      component: consume
    }, {
      path: 'address',
      component: address
    }, {
      path: 'notice',
      component: notice
    }, {
      path: 'teach',
      component: teach
    }]
  }
]

export default new VueRouter({
  // mode: 'history',
  routes,
  strict: process.env.NODE_ENV !== 'production'
})
